const prometheus = require('prom-client');
const register = new prometheus.Registry();

// 添加默认指标
prometheus.collectDefaultMetrics({ register });

// 自定义指标
const httpRequestDurationMicroseconds = new prometheus.Histogram({
  name: 'http_request_duration_seconds',
  help: 'HTTP请求持续时间',
  labelNames: ['method', 'route', 'status_code'],
  buckets: [0.1, 0.5, 1, 1.5, 2, 3, 5]
});

register.registerMetric(httpRequestDurationMicroseconds);

module.exports = { register, metrics: { httpRequestDurationMicroseconds } }; 